package com.atguigu.flink.window.agg;

import com.atguigu.flink.function.WaterSensorMapFunction;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created by Smexy on 2022/12/16
 *
 *      求过去每3个传感器中，vc最大的传感器
 *
 *          常见的聚合操作，无keyBy，不运算
 */
public class Demo5_Agg
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

                env
                   .socketTextStream("hadoop103", 8888)
                   .map(new WaterSensorMapFunction())
                   .keyBy(w -> "a")
                   .countWindow(3)
                   .maxBy("vc")
                   .print();

                try {
                            env.execute();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

    }
}
